package xuexi;


interface IFood{
    public void eat();
}
class Mikl implements IFood{

    @Override
    public void eat() {
        System.out.println("喝牛奶!");
    }
}
class Bread implements IFood{

    @Override
    public void eat() {
        System.out.println("吃面包！" );
    }
}
class Factor{           //工厂代理
    public static IFood getInstane(String className){
        if ("bread".equals(className)){
            return new Bread();
        }else if ("mikl".equals(className)){
            return new Mikl();
        }else{
            return null;
        }
    }
}
public class FactoryModel {
    public static void main(String[] args){
        IFood food=Factor.getInstane("bread");
        //IFood food=new Mikl();
        food.eat();
    }

}
